#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/ioctl.h>
#include <errno.h>
#include <unistd.h> 
#include <string.h>
#include "PowerOff.h"



int fd0;

int InitBacklight (void)
{
	int ret;
	fd0 = open(BACK_LIGHT, O_RDWR,0);
	
	if (fd0 == -1) {
		ret = -1;
		printf ("open back_light fail\n");
		return ret;
	}
		
	ret = ioctl(fd0, SET_FIO_DIR, OUTPUT);
	ret = ioctl(fd0, SET_FIO_INEN, INPUT_DISABLE);	
	write(fd0,"1",sizeof("1")); 
	ret = 0;
	return ret;
}

int SetBacklight (int value)
{
	int ret;
	if (value == POWER_OFF)
		write(fd0,"0",sizeof("0"));
	else
		write(fd0,"1",sizeof("1")); 
	printf ("write IO of backlight \n");
	return 0;
}

int CloseBacklight (void)
{
	close(fd0);
}